package Controler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

public class LaunchServerListener implements ActionListener {
	private Controler controler;
	
	public LaunchServerListener(Controler controler){
		this.controler = controler;
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		String port = (String)JOptionPane.showInputDialog(null,
                "Entrer le numéro de port :\n",
                "Lancer le serveur",
                JOptionPane.PLAIN_MESSAGE,
                null,
                null,
                "2222");
		int intPort;
		if(port.isEmpty()){ 
			intPort = 2222;
			controler.launchServer(intPort);
		}else{
			try{
				intPort = Integer.parseInt(port);
				controler.launchServer(intPort);
			}catch(Exception e){
				System.err.println("Problème parsage port");
			}
		}
		
	}

}
